import 'package:flutter/material.dart';
import 'package:wheel_of_fortune/utils/utils.dart';

class InputText extends StatelessWidget {
  final type;
  final onChange;
  final text;
  final isEnable;
  final flag;
  const InputText({this.type, this.onChange, this.flag = true,this.text, this.isEnable, Key key})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: this.type != null ? null : this.onChange,
      child: Container(
        height: 25,
        decoration: BoxDecoration(
          color: whiteColor,
          borderRadius: BorderRadius.all(Radius.circular(1)),
          boxShadow: [
            BoxShadow(
                color: Color.fromARGB(255, 240, 240, 240),
                offset: Offset(2.0, 2.0),
                blurRadius: 10.0,
                spreadRadius: 0.0),
            BoxShadow(color: Colors.white12, offset: Offset(1.0, 1.0)),
            BoxShadow(color: Colors.white)
          ],
        ),
        child: TextField(
          controller: this.flag?TextEditingController(text: this.text):null,
          enabled: this.type != null,
          //是否隐藏密码
          obscureText: false,
          textCapitalization: TextCapitalization.sentences,
          //控制光标样式
          cursorColor: Colors.black,
          cursorRadius: Radius.circular(1.0),
          cursorWidth: 1.0,
          //自动获取焦点
          autofocus: false,
          //最大长度，设置此项会让TextField右下角有一个输入数量的统计字符串
          // maxLength: 1130,
          maxLines: 1,
          //输入文本的样式
          style: TextStyle(fontSize: 12.0, color: Colors.black),
          //在弹出键盘的时候修改键盘类型
          keyboardType: TextInputType.text,
          //键盘回车键的样式
          textInputAction: TextInputAction.send,
          //内容改变的回调
          onChanged: (text) {
            if (this.type != null && this.onChange != null) {
              this.onChange(text);
            }
          },
          // //内容提交(按回车)的回调
          // onSubmitted: (text) {
          //   print('submit $text');
          // },
          //键盘上按了done
          // onEditingComplete: () {
          //   print(' onEditingComplete');
          // },
          // onTap: (){
          //   this.callBack(data);
          // },
          decoration: InputDecoration(
            hintText: '',
            hintStyle: TextStyle(fontSize: 12, color: Color(0xFFB4B4B4)),
            //填充颜色
            fillColor: Colors.white,
            filled: true,
            // 边框的内边距
            contentPadding: EdgeInsets.only(left: 10),
            // suffix: Icon(data.iconData),
            suffixIcon: this.type != null
                ? null
                : Icon(
                    Icons.arrow_drop_down,
                    color: this.isEnable ? mainColor : Color(0xFFB4B4B4),
                  ),
            //边框
            border: OutlineInputBorder(
                // borderRadius: BorderRadius.circular(2),
                borderSide: BorderSide(
              color: greyDBColor,
              width: 0.5,
            )),
          ),
        ),
      ),
    );
  }
}
